package com.wei.controller;

import com.wei.model.ProductCategoryRelDO;
import com.wei.result.R;
import com.wei.service.IProductCategoryRelService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 产品分类关联表 前端控制器
 * </p>
 *
 * @author 蔡徐坤
 * @since 2025-07-28
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/productCategoryRelDO")
public class ProductCategoryRelController {

    private final IProductCategoryRelService productCategoryRelService;

    //根据分类id查询产品
    @GetMapping("/products/{categoryId}")
    public R<List<Long>> getProductIdsByCategoryId(@PathVariable Long categoryId) {
        return R.ok(productCategoryRelService.getProductIdsByCategoryId(categoryId));
    }
}
